package com.augurit.gzcgwsp.rqqyjyxk.web;

import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import net.sf.json.JSONObject;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.jbpm.api.ProcessEngine;
import org.springframework.beans.factory.annotation.Autowired;
import org.springside.modules.orm.Page;
import org.springside.modules.web.struts2.Struts2Utils;
import com.augurit.common.base.action.BaseAction;
import com.augurit.common.base.action.CrudActionSupport;
import com.augurit.common.syscode.service.ISysCodeService;
import com.augurit.common.syscode.web.form.SysCodeForm;
import com.augurit.common.system.web.auth.form.LoginUserForm;
import com.augurit.common.util.ReflectionUtils;
import com.augurit.common.util.lang.StringUtils;
import com.augurit.gzcgwsp.commonex.util.lang.DateUtilsEX;
import com.augurit.gzcgwsp.excelimportexport.entity.YwRqQyjyxkCyryzkdjb;
import com.augurit.gzcgwsp.excelimportexport.entity.YwRqQyjyxkGdyjgqjgdjb;
import com.augurit.gzcgwsp.excelimportexport.entity.YwRqQyjyxkPzrqgyzdjb;
import com.augurit.gzcgwsp.excelimportexport.entity.YwRqQyjyxkQysbclmc;
import com.augurit.gzcgwsp.excelimportexport.entity.YwRqQyjyxkRqjszdjb;
import com.augurit.gzcgwsp.excelimportexport.entity.YwRqQyjyxkRqjszrypbqk;
import com.augurit.gzcgwsp.excelimportexport.entity.YwRqQyjyxkRqjszzysb;
import com.augurit.gzcgwsp.excelimportexport.entity.YwRqQyjyxkRqqxdylb;
import com.augurit.gzcgwsp.excelimportexport.entity.YwRqQyjyxkRqqxsbylb;
import com.augurit.gzcgwsp.excelimportexport.entity.YwRqQyjyxkRqqxssdjb;
import com.augurit.gzcgwsp.excelimportexport.entity.YwRqQyjyxkRqssdjb;
import com.augurit.gzcgwsp.excelimportexport.entity.YwRqQyjyxkRypbqk;
import com.augurit.gzcgwsp.excelimportexport.entity.YwRqQyjyxkZyaqjsglryzk;
import com.augurit.gzcgwsp.printDoc.service.IYwPrintDocService;
import com.augurit.gzcgwsp.printDoc.web.form.YwPrintDocForm;
import com.augurit.gzcgwsp.rqqyjyxk.entity.YwRqQyjyxk;
import com.augurit.gzcgwsp.rqqyjyxk.entity.YwRqQyjyxkFinalCyryzkdjb;
import com.augurit.gzcgwsp.rqqyjyxk.entity.YwRqQyjyxkFinalGdyjgqjgdjb;
import com.augurit.gzcgwsp.rqqyjyxk.entity.YwRqQyjyxkFinalPzrqgyzdjb;
import com.augurit.gzcgwsp.rqqyjyxk.entity.YwRqQyjyxkFinalQysbclmc;
import com.augurit.gzcgwsp.rqqyjyxk.entity.YwRqQyjyxkFinalRqjszdjb;
import com.augurit.gzcgwsp.rqqyjyxk.entity.YwRqQyjyxkFinalRqjszrypbqk;
import com.augurit.gzcgwsp.rqqyjyxk.entity.YwRqQyjyxkFinalRqjszzysb;
import com.augurit.gzcgwsp.rqqyjyxk.entity.YwRqQyjyxkFinalRqqxdylb;
import com.augurit.gzcgwsp.rqqyjyxk.entity.YwRqQyjyxkFinalRqqxsbylb;
import com.augurit.gzcgwsp.rqqyjyxk.entity.YwRqQyjyxkFinalRqqxssdjb;
import com.augurit.gzcgwsp.rqqyjyxk.entity.YwRqQyjyxkFinalRqssdjb;
import com.augurit.gzcgwsp.rqqyjyxk.entity.YwRqQyjyxkFinalRqssylb;
import com.augurit.gzcgwsp.rqqyjyxk.entity.YwRqQyjyxkFinalRypbqk;
import com.augurit.gzcgwsp.rqqyjyxk.entity.YwRqQyjyxkFinalZyaqjsglryzk;
import com.augurit.gzcgwsp.rqqyjyxk.service.IYwRqQyjyxkService;
import com.augurit.gzcgwsp.rqqyjyxk.web.form.YwRqQyjyxkForm;
import com.augurit.gzcgwsp.ssylb.entity.YwRqRqssylb;
import com.augurit.gzcgwsp.wfex.app.doc.IOaDocCodeServiceEX;
import com.augurit.gzcgwsp.wfex.bi.service.IWfBusTemplateServiceEX;
import com.augurit.gzcgwsp.wfex.bi.service.IWfTemplateAttachmentRefServiceEX;
import com.augurit.gzcgwsp.wfex.bi.web.form.WfTemplateAttachmentRefFormEX;
import com.augurit.gzcgwsp.wfex.common.service.IWfServiceEX;
import com.augurit.gzcgwsp.wfex.common.util.WfUtilsEX;
import com.augurit.gzcgwsp.ywcmn.entity.YwComFinalQyxx;
import com.augurit.gzcgwsp.ywcmn.service.IYwComQyxxService;
import com.augurit.gzcgwsp.ywcmn.web.form.YwComQyxxForm;
import com.augurit.wf.bi.service.IWfBusTemplateService;
import com.augurit.wf.bi.web.form.WfBusInstanceTaskForm;
import com.augurit.wf.bi.web.form.WfBusTemplateForm;
import com.augurit.wf.common.constant.WfConstant;
import com.augurit.wf.common.entity.Jbpm4HistTask;
import com.augurit.wf.common.form.TraceRecord;
import com.augurit.wf.common.form.WfBusSaveResult;
import com.augurit.wf.common.service.IWfBusClientService;
import com.augurit.wf.common.service.IWfService;
import com.augurit.wf.common.util.WfUtils;
import com.augurit.wf.common.web.WfBusClientAction;

@SuppressWarnings("serial")
@Results({
	@Result(name = CrudActionSupport.RELOAD, location = "yw-rq-qyjyxkgd.action", type = "redirect"),
	@Result(name = CrudActionSupport.SUCCESS, location = "/gzcgwsp/rqqyjyxk/YwRqQyjyxk/YwRqQyjyxkgd.jsp"),
	@Result(name = CrudActionSupport.INPUT, location = "/gzcgwsp/rqqyjyxk/YwRqQyjyxk/YwRqQyjyxkgd-input.jsp"),
	@Result(name = WfConstant.PRINT, location = WfConstant.PRINT_JSP),
	@Result(name = WfConstant.PRINT_DIR, location = WfConstant.PRINT_DIR_JSP),
	@Result(name = WfConstant.MAKE_DOCUMENT, location = "/gzcgwsp/wfex/client/common/make-noline-document.jsp"),
	@Result(name = "showview", location = "/gzcgwsp/rqqyjyxk/YwRqQyjyxk/YwRqQyjyxk-view.jsp"),
	@Result(name = "view", location = "/gzcgwsp/rqqyjyxk/YwRqQyjyxk/YwRqQyjygd-view.jsp")
})
public class YwRqQyjyxkgdAction extends WfBusClientAction<YwRqQyjyxkForm>{
	private Log log=LogFactory.getLog(YwRqQyjyxkgdAction.class);
	private SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    @Autowired
    private IWfService wfService;
	@Autowired
	private IYwRqQyjyxkService ywRqQyjyxkService;
    @Autowired
    private IYwComQyxxService qyxxService;
    @Autowired
    private ISysCodeService syscodeService;
    @Autowired
    private IWfBusTemplateService wfBusTemplateService;
    @Autowired
    private ProcessEngine processEngine;
    @Autowired
    private IWfTemplateAttachmentRefServiceEX wfTemplateAttachmentRefServiceEX;
    @Autowired
	private IYwPrintDocService ywPrintDocService;    
    @Autowired
    private IWfServiceEX wfServiceEX;
    @Autowired
    private IOaDocCodeServiceEX oaDocCodeServiceEX;    
    @Autowired
    private IWfBusTemplateServiceEX wfBusTemplateServiceEX;
    
	private YwRqQyjyxkForm form;
	private Long id;
	private Long[] checkedIds;
	private Page<YwRqQyjyxkForm> page = new Page<YwRqQyjyxkForm>(10);

	public String printcz() throws Exception {
		String taskId=getRequest().getParameter("taskInstDbid");
		String activName="";
		if(StringUtils.isNotBlank(taskId)){
		  	WfBusInstanceTaskForm instance = wfService.getWfBusInstanceTaskById(Long.valueOf(taskId), this.getLoginUserName());
			activName=instance.getActivityName();
		    getRequest().setAttribute("activName", activName);
		}else{
			 getRequest().setAttribute("activName", "");
		}
		if(!"gdrqkhfile".equals(form.getFileCode()) && 
				!"gdbaseInfoFile".equals(form.getFileCode())){//除了考核表，其他的文书都加载已经存在的
			if(form.getId() != null && form.getId() > 0){
				form.setCbyw("燃气经营许可证审批");
				form.setCbyw2("燃气经营许可证审批");
				form.setCbyw3("燃气经营许可证审批");
				form.setCbyw4("燃气经营许可证审批");
	    		List<YwPrintDocForm> ywPrintDocFormList = ywPrintDocService.get(form.getTemplateCode(), form.getFileCode(), form.getId());
	        	if(ywPrintDocFormList!=null && ywPrintDocFormList.size()>0){
	    			return WfConstant.PRINT_DIR;
	    		}
	    	}
		}
		 this.setValue(form);
        return WfUtilsEX.wfBusPrint(form,form.getId(),activName);
    }
	/**
	 * 分页查询
	 */
	@Override
	public String list() throws Exception {
		ywRqQyjyxkService.search(page, form);
		return SUCCESS;
	}

	/**
	 * 新增或修改
	 */
	@Override
	public String input() throws Exception {
        this.setOpinions();
        
        getRequest().setAttribute("CurrUserName", this.getLoginUser().getUser().getUserName());
        List<SysCodeForm> sqdwlx = syscodeService.getItems("YW_SQDW_LX");
        List<SysCodeForm> ywHbbm = syscodeService.getItems("ALL_HBBM");
        getRequest().setAttribute("sqdwlx", sqdwlx);
        getRequest().setAttribute("ywhbbm", ywHbbm);
		return INPUT;
	}
	
	

	/**
	 * 环节名称判断是哪个环节的意见
	 */
	private void setOpinion(String hjmc, List<TraceRecord> traceRecords){
		StringBuilder opinionsStr = new StringBuilder("");
		if(traceRecords != null && traceRecords.size() > 0){
				for(TraceRecord traceRecord:traceRecords){
					if(traceRecord.getHandleComments() != null && traceRecord.getHandleComments().trim().length() > 0){
						opinionsStr.append(traceRecord.getHandleComments());
					}
				}
		}
	}
	
	
	/**
     * 保存业务并关联流程实例
     */
    public String wfBusSave()  {
    	try {
    		//修改每次提交新增申请号码，比如表单提交的受理号是gz26120320XXXXX，但另外的acceptNo2是120327000636
        	if(StringUtils.isNotBlank(form.getAcceptNo()) && form.getAcceptNo().indexOf("XXXX")>0){
        		if(StringUtils.isNotBlank(form.getAcceptNo2()) && form.getAcceptNo2().indexOf("XXXX")<0){
        			form.setAcceptNo(form.getAcceptNo2());
        		}
        	}
        if (form.getQyid() == null) {
            YwComQyxxForm qyxxForm = qyxxService.getFormBySqdw(form.getSqdw(),form.getTemplateCode());
            if (qyxxForm != null) {
                WfUtils.renderWfFailtureJson("该企业名称已经存在，请点击选择企业从企业列表中选择该企业！");
                return null;
            }
        }
    	String isYsl = super.getParameter("isYsl");

    	
        WfBusInstanceTaskForm task = this.wfBusSave((IWfBusClientService)ywRqQyjyxkService, form, YwRqQyjyxk.class.getSimpleName());
        String durationExpression = wfServiceEX.getProcDueExpressIonByTaskInstDbid(task.getTaskInstDbid());
        if (form.getDfsj() == null) {//答复时间
        	Date dfsj = wfServiceEX.calculateDueDate(form.getLarq(), durationExpression);
        	form.setDfsj(dfsj);
        	this.save();
        }

        if (StringUtils.isNotBlank(isYsl) && "1".equals(isYsl)) {
        	String executionId =  processEngine.getHistoryService().createHistoryTaskQuery().taskId(task.getTaskInstDbid().toString()).uniqueResult().getExecutionId();
            processEngine.getExecutionService().jumpToActivity(executionId, "cksa");
            form.setYsl(null);
            ywRqQyjyxkService.changeYslState(form.getId(), 2l,null);
        }
		this.save();
        WfUtils.renderWfBusSaveJson(task, form);
		
		} catch (Exception e) {
			WfUtils.renderWfFailtureJson("请检查输入内容长度是否过大!");
		}
        return null;
    }
    
    
    public String wfBusYslTuih() throws Exception {
    	try {
    		ywRqQyjyxkService.wfBusYslTuih(form, this.getLoginUser());
			WfBusSaveResult result = new WfBusSaveResult(true, null);
			result.setTask(new WfBusInstanceTaskForm());
			Struts2Utils.renderJson(result);
		} catch (RuntimeException e) {
			e.printStackTrace();
		}
        return null;
    }

	/**
	 * 保存新增或者修改的Form对象
	 */
	@Override
	public String save() throws Exception {
		ywRqQyjyxkService.save(form);
		return RELOAD;
	}

	/**
	 * 删除一条记录
	 */
	@Override
	public String delete() throws Exception {
		ywRqQyjyxkService.delete(id);
		return RELOAD;
	}
	
	/**
	 * 删除多条记录
	 */
	@Override
	public String deleteMore() throws Exception{
		ywRqQyjyxkService.delete(checkedIds);
		return RELOAD;
	}
	
	/**
	 * 
	 * @return
	 */
	public String getJyxk() throws Exception{
	    
	    //Struts2Utils.renderJson(form);
	    return CrudActionSupport.INPUT;
	}
	 /**
     * 制文
     * @return
     * @throws Exception
     */
    public String makeDocument() throws Exception {
        if (StringUtils.isNotBlank(form.getRedHeadFileId())) {
            String redHeadFilePath = wfBusTemplateServiceEX.getPrintTemplatePath(Long.parseLong(form.getRedHeadFileId()));
            form.setRedHeadFilePath(redHeadFilePath);
        }
         //加载收件通知书里面的附件
		 String isred=getRequest().getParameter("isred");
		 //如果要打印红头
		 if("yes".equals(isred)){
			 String redHeadFilePath = wfBusTemplateServiceEX.getRedFile(form.getTemplateCode());
		      form.setRedHeadFilePath(redHeadFilePath);
		 }
        String templateCode = getTemplateCode();
        if(templateCode != null && templateCode.trim().length() > 0){
            String printTemplatePath = wfBusTemplateServiceEX.getPrintTemplatePath(templateCode, WfTemplateAttachmentRefFormEX.ZHENGWEN_TEMPLATE_TYPE);
            form.setTemplatePath(printTemplatePath);
            logger.info("制文打印模版文件printTemplatePath------>"+printTemplatePath);
            WfTemplateAttachmentRefFormEX wfTemplateAttachmentRefFormEX = (WfTemplateAttachmentRefFormEX)wfTemplateAttachmentRefServiceEX.get(Long.parseLong(form.getZhengwenFileId()));
            String zhengwenPath = wfTemplateAttachmentRefFormEX.getFilePath() + "/" + wfTemplateAttachmentRefFormEX.getFileRealName();
            logger.info("制文模版文件路径------>"+printTemplatePath);
            form.setZhengwenPath(zhengwenPath);
            form.setCurDate(DateUtilsEX.convertDate2Chinese(new Date()));
            form.setCurDate4(form.getCurDate2());
            form.setCurDate5(form.getCurDate2());
            form.setCurYear(String.valueOf(Calendar.getInstance().get(Calendar.YEAR)));
            form.setCbyw("燃气经营许可证审批");
            form.setCbyw2("燃气经营许可证审批");
            form.setCbyw3("燃气经营许可证审批");
            form.setCbyw4("燃气经营许可证审批");
            
            Long seq=oaDocCodeServiceEX.getCurSeqAndAddSeq(templateCode, wfTemplateAttachmentRefFormEX.getFileCode(),form.getId());
            if(seq.intValue()<10){
	        	  form.setCurSeq("0"+String.valueOf(seq));
	        }else{
	        	  form.setCurSeq(String.valueOf(seq));
	        }
            if("bzsltzs".equals(wfTemplateAttachmentRefFormEX.getFileCode())){
            	List<YwPrintDocForm> ywPrintDocFormList = ywPrintDocService.get(form.getTemplateCode(),"bzcltzs", form.getId());
                if(ywPrintDocFormList!=null&&ywPrintDocFormList.size()>0){
                	YwPrintDocForm ywPrintDocForm=ywPrintDocFormList.get(0);
                	form.setWh(ywPrintDocForm.getFileNum());
                	form.setWh2(ywPrintDocForm.getFileNum());
                }            	
            }
            
          //---获取受理通知书时间---韩修改
            YwRqQyjyxkForm sltjsForm=new YwRqQyjyxkForm();
            sltjsForm.setFileCode("sltzs");
            List<YwPrintDocForm> ywPrintDocFormList = ywPrintDocService.get(form.getTemplateCode(),sltjsForm.getFileCode(), form.getId());
            if(ywPrintDocFormList!=null&&ywPrintDocFormList.size()>0){
            	YwPrintDocForm ywPrintDocForm=ywPrintDocFormList.get(0);
            	form.setSlDate(DateUtilsEX.convertCommonDate(ywPrintDocForm.getCreatDate()));
            }else{//受理通知书没有制作时加入
            	form.setSlDate(DateUtilsEX.convertCommonDate(form.getLarq()));
            }
	       
            WfUtilsEX.wfBusPrint(form);
            
            getRequest().setAttribute("isunified", false);//是否全委统一
            BaseAction.getRequest().setAttribute("templateFilePath",zhengwenPath);
            BaseAction.getRequest().setAttribute("fileCode", wfTemplateAttachmentRefFormEX.getFileCode());
            BaseAction.getRequest().setAttribute("entityId", form.getId());
            BaseAction.getRequest().setAttribute("seq", form.getCurSeq());
            BaseAction.getRequest().setAttribute("templateId", wfTemplateAttachmentRefFormEX.getId());
//            BaseAction.getRequest().setAttribute("busType", OaFawen.class.getSimpleName());
        }
        return WfConstant.MAKE_DOCUMENT; 
       }
    
    	/**
    	 * 主要用于制文的安全考核表
    	 * @param form
    	 */
    	private void setValue(YwRqQyjyxkForm form){
    		Field[] field = form.getClass().getDeclaredFields();    
            for(int j=0 ; j<field.length ; j++){     
                try {
    				String fieldName = field[j].getName();  
    				String type = field[j].getGenericType().toString();   
    				if(fieldName.length()>4){
    					if(fieldName.substring(0,4).equals("khjg")){
	    				    Method m = form.getClass().getMethod("get"+StringUtils.capitalize(fieldName));
	    				    String value = (String) m.invoke(form);   
	    				    if("1".equals(value)){
	    				        ReflectionUtils.setFieldValue(form, fieldName, "合格");
	    				    }else if("0".equals(value)){
	    				    	 ReflectionUtils.setFieldValue(form, fieldName, "不合格");
	    				    }
    					}
    				}
    				if(fieldName.length()>6){
    				 if(fieldName.substring(0,6).equals("sqkhjg")){
    					    Method m = form.getClass().getMethod("get"+StringUtils.capitalize(fieldName));
   	    				    String value = (String) m.invoke(form);   
   	    				    if("1".equals(value)){
   	    				        ReflectionUtils.setFieldValue(form, fieldName, "合格");
   	    				    }else if("0".equals(value)){
   	    				    	 ReflectionUtils.setFieldValue(form, fieldName, "不合格");
   	    				    }
    					}
    				}
    			} catch (Exception e) {
    				log.error("转换异常"+e);
    			}
            }
    	}
    	
    
	/**
	 * 进入导入正式企业信息页面
	 * @return
	 * @author @zhangjun
	 * @date 2011-10-16
	 */
	public String showview() throws Exception{
        getRequest().setAttribute("CurrUserName", this.getLoginUser().getUser().getUserName());
        if(form!=null){
            Long qyid=form.getQyid();
            YwRqQyjyxkFinalCyryzkdjb  finalcyryzk=null;
            YwRqQyjyxkCyryzkdjb cyryzk=null;
            YwRqQyjyxkFinalRqqxssdjb finalqxss=null;
            YwRqQyjyxkRqqxssdjb qxss=null;
            YwRqQyjyxkFinalPzrqgyzdjb finalrqqxssgyz=null;
            YwRqQyjyxkPzrqgyzdjb rqqxssgyz=null;
            YwRqQyjyxkRqssdjb rqssdjb=null;
            YwRqQyjyxkFinalRqssdjb finalRqssdjb=null;
            YwRqQyjyxkFinalRqjszdjb finalrqjszdjb=null;
            YwRqQyjyxkRqjszdjb rqjszdjb=null;
            
            //最终企业表
            YwComFinalQyxx finalEntity=this.ywRqQyjyxkService.getYwComFinalQyxx(qyid);
            //查询最终从业人员
            List<YwRqQyjyxkFinalCyryzkdjb> finalcyryzks=this.ywRqQyjyxkService.getFinalCyrys(qyid);
            //查询从业人员状况
            List<YwRqQyjyxkCyryzkdjb> cyryzks=this.ywRqQyjyxkService.getCyrys(qyid,form.getAcceptNo());
            if(finalcyryzks!=null &&finalcyryzks.size()>0){
                finalcyryzk=finalcyryzks.get(0);
            }
            if(cyryzks!=null &&cyryzks.size()>0){
                cyryzk=cyryzks.get(0);
            }
            //查询最终主要安全人员、技术管理
            List<YwRqQyjyxkFinalZyaqjsglryzk> finalzyaqjs=this.ywRqQyjyxkService.getFinalZyaqjs(qyid);
            //查询主要安全人员、技术管理
            List<YwRqQyjyxkZyaqjsglryzk> zyaqjs=this.ywRqQyjyxkService.getZyaqjs(qyid,form.getAcceptNo());
            //查询最终燃气抢险设备
            List<YwRqQyjyxkFinalRqqxsbylb> finalRqqxsbs=this.ywRqQyjyxkService.getFinalRqqxsbs(qyid);
            //查询燃气抢险设备
            List<YwRqQyjyxkRqqxsbylb> rqqxsbs=this.ywRqQyjyxkService.getRqqxsbs(qyid,form.getAcceptNo());
          //查询最终燃气抢险点
            List<YwRqQyjyxkFinalRqqxdylb> finalRqqxds=this.ywRqQyjyxkService.getFinalRqqxds(qyid);
            //查询燃气抢险点
            List<YwRqQyjyxkRqqxdylb> rqqxsqxds=this.ywRqQyjyxkService.getRqqxds(qyid,form.getAcceptNo());
            //查询最终燃气抢险设施
            List<YwRqQyjyxkFinalRqqxssdjb> finalRqqxss=this.ywRqQyjyxkService.getFinalRqqxss(qyid);
            //查询燃气抢险设施
            List<YwRqQyjyxkRqqxssdjb> rqqxss=this.ywRqQyjyxkService.getRqqxss(qyid,form.getAcceptNo());
           //最终燃气设施供应站
            List<YwRqQyjyxkFinalPzrqgyzdjb> finalrqqxssgyzs=this.ywRqQyjyxkService.getRqqxssGyz(qyid);
           //燃气设施供应站
            List<YwRqQyjyxkPzrqgyzdjb> rqqxssgyzs=this.ywRqQyjyxkService.getRqqxssGyz(qyid,form.getAcceptNo());
            //燃气设施登记表
            List<YwRqQyjyxkFinalRqssdjb> finalrqqxssdjs=this.ywRqQyjyxkService.getRqqxssfinalDjbs(qyid);
            List<YwRqQyjyxkRqssdjb> rqqxssdjs=this.ywRqQyjyxkService.getRqqxssDjbs(qyid,form.getAcceptNo());
            //瓶装燃气供应站人员配备情况
            List<YwRqQyjyxkFinalRypbqk>  finalpzrypbqks=ywRqQyjyxkService.getPzrybqks(qyid);
            List<YwRqQyjyxkRypbqk>  pzrypbqks=ywRqQyjyxkService.getPzrybqks(qyid,form.getAcceptNo());
            
            //燃气接收站、储配站、汽车加气站登记表
            List<YwRqQyjyxkFinalRqjszdjb> finalrqjszdjbs=this.ywRqQyjyxkService.getFinalRqjszdjb(qyid);
            List<YwRqQyjyxkRqjszdjb> rqjszdjbs=this.ywRqQyjyxkService.getRqjszdjb(qyid);
            //燃气接收站、储配站、汽车加气站主要设备
            List<YwRqQyjyxkRqjszzysb> rqjszzysbs=this.ywRqQyjyxkService.getzysbs(qyid,form.getAcceptNo());
            List<YwRqQyjyxkFinalRqjszzysb> finalrqjszzysbs=this.ywRqQyjyxkService.getfinalzysbs(qyid);
            
            //燃气接收站、储配站、汽车加气站人员配备情况
            List<YwRqQyjyxkRqjszrypbqk> finalrqjszrypbqks=this.ywRqQyjyxkService.getjszrypbqks(qyid,form.getAcceptNo());
            List<YwRqQyjyxkFinalRqjszrypbqk> rqjszrypbqks=this.ywRqQyjyxkService.getfinaljszrypbqks(qyid);
            
            //企业申报材料目录
            List<YwRqQyjyxkFinalQysbclmc> finalsbclmcs=this.ywRqQyjyxkService.getFinalQysbclmc(qyid);
            List<YwRqQyjyxkQysbclmc> sbclmcs=this.ywRqQyjyxkService.getQysbclmc(qyid,form.getAcceptNo());
            
            if(finalrqqxssgyzs!=null &&finalrqqxssgyzs.size()>0){
                finalrqqxssgyz=finalrqqxssgyzs.get(0);
            }
            if(rqqxssgyzs!=null &&rqqxssgyzs.size()>0){
                rqqxssgyz=rqqxssgyzs.get(0);//燃气设施供应站
            }
            
            if(finalRqqxss!=null &&finalRqqxss.size()>0){
                finalqxss=finalRqqxss.get(0);
            }
            if(rqqxss!=null &&rqqxss.size()>0){
                qxss=rqqxss.get(0);
            }
            if(rqqxssdjs!=null && rqqxssdjs.size()>0){
                rqssdjb=rqqxssdjs.get(0);
            }
            if(finalrqqxssdjs!=null && finalrqqxssdjs.size()>0){
                finalRqssdjb=finalrqqxssdjs.get(0);
            }
            if(finalrqjszdjbs!=null && finalrqjszdjbs.size()>0){
                finalrqjszdjb=finalrqjszdjbs.get(0);
            }
            if(rqjszdjbs!=null && rqjszdjbs.size()>0){
                rqjszdjb=rqjszdjbs.get(0);
            }
            getRequest().setAttribute("finalrqjszrypbqks", finalrqjszrypbqks);
            getRequest().setAttribute("rqjszrypbqks", rqjszrypbqks);
            
            getRequest().setAttribute("rqjszzysbs", rqjszzysbs);
            getRequest().setAttribute("finalzzysbs", rqjszzysbs);
            getRequest().setAttribute("finalrqjszzysbs", finalrqjszzysbs);
            getRequest().setAttribute("finalcyryzk", finalcyryzk);
            getRequest().setAttribute("finalrqqxssgyz", finalrqqxssgyz);
            getRequest().setAttribute("rqqxssgyz", rqqxssgyz);
            getRequest().setAttribute("cyryzk", cyryzk);
            getRequest().setAttribute("finalzyaqjs", finalzyaqjs);
            getRequest().setAttribute("zyaqjs", zyaqjs);
            getRequest().setAttribute("finalRqqxsbs", finalRqqxsbs);
            getRequest().setAttribute("rqqxsbs", rqqxsbs);
            getRequest().setAttribute("finalRqqxds", finalRqqxds);
            getRequest().setAttribute("rqqxsqxds", rqqxsqxds);
            getRequest().setAttribute("finalqxss", finalqxss);
            getRequest().setAttribute("qxss", qxss);
            getRequest().setAttribute("finalsbclmcs", finalsbclmcs);
            getRequest().setAttribute("sbclmcs", sbclmcs);
            getRequest().setAttribute("finalrqjszdjbs", finalrqjszdjbs);
            getRequest().setAttribute("rqjszdjbs", rqjszdjbs);
            getRequest().setAttribute("finalRqssdjb", finalRqssdjb);
            getRequest().setAttribute("rqssdjb", rqssdjb);
            getRequest().setAttribute("finalrqqxssdjs", finalrqqxssdjs);
            getRequest().setAttribute("rqqxssdjs", rqqxssdjs);
            
            getRequest().setAttribute("finalpzrypbqks", finalpzrypbqks);
            getRequest().setAttribute("pzrypbqks", pzrypbqks);
            getRequest().setAttribute("finalrqjszdjb", finalrqjszdjb);
            getRequest().setAttribute("finalrqqxssgyzs", finalrqqxssgyzs);
            getRequest().setAttribute("rqqxssgyzs", rqqxssgyzs);
            getRequest().setAttribute("finalEntity", finalEntity);
        }
        
        List<SysCodeForm> sqdwlx = syscodeService.getItems("YW_SQDW_LX");
        List<SysCodeForm> ywHbbm = syscodeService.getItems("ALL_HBBM");
        getRequest().setAttribute("sqdwlx", sqdwlx);
        getRequest().setAttribute("ywhbbm", ywHbbm);
		return "showview";
	}
	
	/**
	 * 到修改企业信息页面
	 * @return
	 * @throws Exception 
	 */
	public String toUpdate() throws Exception{
	        getResponse().setCharacterEncoding("utf-8");
	        JSONObject jsonObject = JSONObject.fromObject(form); 
	        String json=jsonObject.toString();
	        getResponse().getWriter().print(json);      
	        return null;
	}

	/**
	 * 修改企业信息
	 * @return
	 * @throws Exception
	 */
	public String doUpdate() throws Exception{
		Enumeration enu = getRequest().getParameterNames();
        String jsonStr="";
        while(enu.hasMoreElements()) {   
            String paraName = (String)enu.nextElement();   
            if(StringUtils.isNotBlank(paraName)){        
                jsonStr=paraName;
            }
        }  
        JSONObject jsonObject = JSONObject.fromObject(jsonStr); 
        String jyxkid=(String) jsonObject.get("jyxkid");
        String clsj=(String) jsonObject.get("clsj");//json对象转换时间问题
        YwRqQyjyxkForm entity=(YwRqQyjyxkForm) JSONObject.toBean(jsonObject, YwRqQyjyxkForm.class);
        
        if(StringUtils.isNotBlank(clsj)){
            Date clsjDate=DateUtilsEX.dateFormate(clsj, "yyyy年MM月dd日");
            entity.setClsj(clsjDate);
        }
        if(entity.getId()==null){
        	entity.setId(Long.valueOf(jyxkid));
        }
        try {
            ywRqQyjyxkService.doUpdate(entity);
            getResponse().getWriter().print("success");
        } catch (Exception e) {
            log.error("修改失败"+e);
            getResponse().getWriter().print("fail");
        }
        
         return null;
   }
    /*
     * 入库的时候转换form 只转换经营许可的内容
     */
   private void changeForm(YwRqQyjyxkForm jyxk){
	   form.setSqdw(jyxk.getSqdw());
	   form.setAddress(jyxk.getAddress());
	   form.setClsj(jyxk.getClsj());
	   form.setYyzzzch(jyxk.getYyzzzch());
	   form.setLxr(jyxk.getLxr());
	   form.setLxdh(jyxk.getLxdh());
	   form.setDzyx(jyxk.getDzyx());
	   form.setCz(jyxk.getCz());
	   form.setQywz(jyxk.getQywz());
	   form.setFddbr(jyxk.getFddbr());
	   form.setFddbrZw(jyxk.getFddbrZw());
	   form.setFddbrZc(jyxk.getFddbrZc());
	   form.setZyfzr(jyxk.getZyfzr());
	   form.setZyfzrZc(jyxk.getZyfzrZc());
	   form.setZyfzrZw(jyxk.getZyfzrZw());
	   form.setJsfzr(jyxk.getJsfzr());
	   form.setJsfzrZc(jyxk.getJsfzrZc());
	   form.setJsfzrZw(jyxk.getJsfzrZw());
	   form.setZczj(jyxk.getZczj());
	   form.setQylx(jyxk.getQylx());
	   form.setJyfw(jyxk.getJyfw());
	   form.setGqqy(jyxk.getGqqy());
	   form.setFwdh(jyxk.getFwdh());
	   form.setQxdh(jyxk.getQxdh());
	   form.setQyjj(jyxk.getQyjj());
   }
   
	/**
	 * 保存设施一览表
	 * @return
	 */
	public String saveSsylb(){
	    Map map=getMapByRequest(getRequest());
	    JSONObject jsonObject = JSONObject.fromObject(map); 
	    YwRqRqssylb entity=(YwRqRqssylb) JSONObject.toBean(jsonObject, YwRqRqssylb.class);
	    List<YwRqRqssylb> ssylbs=new ArrayList<YwRqRqssylb>();
	    ssylbs.add(entity);
	    ywRqQyjyxkService.saveSsylbs(ssylbs);
	    return null;
	}
	
	/**
	 * 删除设施一览表
	 * @return
	 */
	public String deleteSsylb(){
	    String ssylbid=getRequest().getParameter("ssylbid");
	    if(StringUtils.isNotBlank(ssylbid)){
	        ywRqQyjyxkService.delSsylb(Long.valueOf(ssylbid));
	    }
	   
	    return null;
	}
	
	 /**
     * 删除所有设施一览表
     * @return
     */
    public String deleteSsylbs(){
        Long qyjyxkid=form.getId();
        String acceptNo=form.getAcceptNo();
        List<YwRqRqssylb> list=this.ywRqQyjyxkService.getSsylbs(qyjyxkid,acceptNo);
        for(YwRqRqssylb entity:list){
            ywRqQyjyxkService.delSsylb(entity.getSsylbid());
        }
     
        return null;
    }
    
    /**
     * 获取股东股权
     * @return
     * @throws IOException 
     */
	public String getgdgqs() throws IOException{
	    Long qyid=form.getQyid();
	    String acceptNo=form.getAcceptNo();
	    List<YwRqQyjyxkGdyjgqjgdjb> entitys=this.ywRqQyjyxkService.getGdyjs(qyid,acceptNo);
	    List<YwRqQyjyxkFinalGdyjgqjgdjb> list=this.ywRqQyjyxkService.getFinalGdyjs(qyid);
	    Map<String,List> map=new HashMap<String,List>();
	       map.put("gdgqdatas", entitys);
	       map.put("finalDatas", list);
	       JSONObject jsonObject = JSONObject.fromObject(map); 
	       getResponse().getWriter().print(jsonObject.toString());
	    return null;
	}
	
	
	/**
	 * 设施一览表
	 * @return
	 * @throws Exception 
	 */
	public String getsslyb() throws Exception{
	   Long qyid=form.getQyid();
       Long qyjyxkid=form.getId();
	   String acceptNo=form.getAcceptNo();
	   List<YwRqRqssylb> list=this.ywRqQyjyxkService.getSsylbs(qyjyxkid,acceptNo);
	   List<YwRqQyjyxkFinalRqssylb> finalDatas=this.ywRqQyjyxkService.getFinalSsylbDatas(qyid);
	   Map<String,List> map=new HashMap<String,List>();
	   map.put("ssylb", list);
	   map.put("finalDatas", finalDatas);
	   JSONObject jsonObject = JSONObject.fromObject(map); 
	   getResponse().getWriter().print(jsonObject.toString());
	   return null;
	}

	/**
	 * 保存股东信息
	 * @return
	 */
	public String saveGdGq(){
	    Map map=getMapByRequest(getRequest());
	    String gdId=(String) map.get("gdId");
	    if(StringUtils.isNotBlank(gdId)){
	        map.put("id", gdId);//避免与经营许可Id重复
	    }
        JSONObject jsonObject = JSONObject.fromObject(map);
        YwRqQyjyxkGdyjgqjgdjb entity=(YwRqQyjyxkGdyjgqjgdjb) JSONObject.toBean(jsonObject, YwRqQyjyxkGdyjgqjgdjb.class);
        ywRqQyjyxkService.saveGdInfos(entity);
	   return null; 
	}
	
	public String deletegdgq(){
	    String gdId=getRequest().getParameter("gdId");
        if(StringUtils.isNotBlank(gdId)){
            ywRqQyjyxkService.deleteGdgq(Long.valueOf(gdId));
        }
       
        return null;
	}

	/**
	 * 获取股东股权
	 * @return
	 * @throws IOException 
	 */
	public String getGdgq() throws IOException{
	    String gdId=getRequest().getParameter("gdid");
	    if(StringUtils.isNotBlank(gdId)){
	        YwRqQyjyxkGdyjgqjgdjb entity=this.ywRqQyjyxkService.getGdyj(Long.valueOf(gdId));
	        JSONObject jsonObject = JSONObject.fromObject(entity); 
	       getResponse().getWriter().print(jsonObject.toString());
	    }
        return null;
	}
	
	/**
	 * 到办结环节导入
	 * @return
	 */
	public String importFinalQyData(){
	    Map map=getMapByRequest(getRequest());
	    //导入企业正式信息
	    Map msgMap=ywRqQyjyxkService.importFinalQyData(form,map);
	    
	    return null;
	}
	
	public void getSslbUrl(){
		String contextPath=getRequest().getSession().getServletContext().getRealPath("");
		System.out.println("contextPath =============="+contextPath);
		ywRqQyjyxkService.getSslbUrl(contextPath);
	}
	
	
	/**
	 * 准备页面模型
	 */
	@Override
	protected void prepareModel() throws Exception {
		if(id != null){
			form = ywRqQyjyxkService.getJyxk(id, "gd");
		}
		else
			form = new YwRqQyjyxkForm();
		if (form.getSarq() == null) {
            form.setSarq(new Date());
        }
		
		if (StringUtils.isBlank(form.getAcceptNo())) {
			String rq = DateUtilsEX.getYearAndMonthAndDay();
        	form.setAcceptNo("gz26"+rq+"XXXXX");
        }
		if(StringUtils.isBlank(form.getDzyx())){
			if(StringUtils.isNotBlank(form.getEmail())){
				form.setDzyx(form.getEmail());
			}
		}
		if (StringUtils.isBlank(form.getCbyw())) {
            WfBusTemplateForm wfBusTemplateForm = wfBusTemplateService.getByTemplateCode(getTemplateCode());
            if (wfBusTemplateForm != null) {
                form.setCbyw(wfBusTemplateForm.getTemplateName());
            }
        }
		
		if (StringUtils.isBlank(form.getSjr())) {
            form.setSjr(this.getLoginUser().getUser().getUserName());
        }
		
		if (StringUtils.isBlank(form.getCbbm())) {
            form.setCbbm("燃气处");
        }
		if (StringUtils.isBlank(form.getJbrxm())) {
            form.setJbrxm(this.getLoginUser().getUser().getUserName());
            form.setJbrdh(this.getLoginUser().getUser().getOfficeTel());
            form.setJbrxm2(form.getJbrxm());
            form.setJbrdh2(form.getJbrdh());
        }
		if(form.getLarq() == null){
			Date newLarq = new Date();
			form.setLarq(newLarq);
	        form.setLarq2(newLarq);
		}else{
			form.setLarq2(form.getLarq());
		}
        form.setSajg("广州市城市管理委员会");
        form.setSajg2(form.getSajg());
        form.setSajg3(form.getSajg());
        form.setSajg4(form.getSajg());
        form.setSajg5(form.getSajg());
        form.setSajg6(form.getSajg());
        try {
            if (form.getSarq() == null) {
                form.setSarq(new Date());
            }
            if (form.getCpsj() == null) {
                form.setCpsj(new Date());
            }
            if (form.getSqrq() == null) {
                form.setSqrq(new Date());
            }
            if(getTaskInstDbid() != null){
            	this.findJbrspUtil();	//获取审批过程中的意见列表
            	this.findCldspUtil();
            	this.findWldspUtil();
            	
            	this.cpbJbrspUtil();
            	this.cpbCldspUtil();
            	this.cpbWldspUtil();
            }
        } catch (Exception e) {
            // TODO: handle exception
        }
    	LoginUserForm uform=(LoginUserForm)this.getRequest().getSession().getAttribute("SES_LOGIN_USER");
		String username=uform.getUser().getUserName();
        //获取延期天数
    	int yqtsInt = wfServiceEX.getYqtsByProcInstId(super.getProcInstId());
    	form.setYqts(String.valueOf(yqtsInt));
    	//补交告知原因
    	if(form.getBjgzyy()==null){
    		form.setBjgzyy(this.getOpinion("jbrsl"));
    	}
    	//补交告知时间
    	if(form.getBjgzsj()==null){
    		form.setBjgzsj(new Date());
    	}
    	//受理告知时间
//    	if(form.getBjslsj()==null){
//    		form.setBjslsj(new Date());
//    	}
    	
    	//补交告知受理地点
    	if(form.getBjsljtdd()==null){
    		form.setBjsljtdd("广州市城市管理委员会");
    	}
    	//答复时间
    	if(id!=null && StringUtils.isNotBlank(this.getTemplateCode())){
    		Date date=wfServiceEX.getDfsjByTempleteCode(this.getTemplateCode(),id);
    		form.setDfsj(date);
    	}
    	if(form.getShbShsj() == null){
    		form.setShbShsj(new Date());
    	}
    	if(form.getKhbShsj() == null){
    		form.setKhbShsj(new Date());
    	}
	}
	
	
	
	/**
	 * from加载	经办人审批意见列表工具方法
	 */
	private void findJbrspUtil(){
		String names = "'jbrsl' , 'jbrsj'";
		List<Jbpm4HistTask> list = wfServiceEX.getHandleCommentsByTaskInstDbidAndActivityNames(getTaskInstDbid(),names);
		StringBuffer jbrspYj = new StringBuffer();
		for(int i=list.size()-1;i>=0;i--){//只取一条记录
			if(StringUtils.isNotBlank(list.get(i).getHandleComments())){
			jbrspYj.append(list.get(i).getHandleComments());
			form.setJbrslsj(list.get(i).getHandleCommentsTime());
			form.setJbrslxm(list.get(i).getAssigneeName());
			 break;
			}
		}
		form.setJbrsl(jbrspYj.toString());
	}
	

	
	
	/**
	 * from加载	处领导审批意见列表工具方法
	 */
	private void findCldspUtil(){
		String names = "'cfgldsh' , 'czgldsh'";
		List<Jbpm4HistTask> list = wfServiceEX.getHandleCommentsByTaskInstDbidAndActivityNames(getTaskInstDbid(),names);
		StringBuffer cldspYj = new StringBuffer();
		for(int i=list.size()-1;i>=0;i--){//只取一条记录
			if(StringUtils.isNotBlank(list.get(i).getHandleComments())){
				cldspYj.append(list.get(i).getHandleComments());
				form.setCldspsj(list.get(i).getHandleCommentsTime());
				form.setCldspxm(list.get(i).getAssigneeName());
				break;
			}
		}
		form.setCldsp(cldspYj.toString());
	}
	/**
	 * from加载	委领导审批意见列表工具方法
	 */
	private void findWldspUtil(){
		String names = "'wfgldsh' , 'wzgldsp'";
		List<Jbpm4HistTask> list = wfServiceEX.getHandleCommentsByTaskInstDbidAndActivityNames(getTaskInstDbid(),names);
		StringBuffer wldspYj = new StringBuffer();
		for(int i=list.size()-1;i>=0;i--){//只取一条记录
			if(StringUtils.isNotBlank(list.get(i).getHandleComments())){
			wldspYj.append(list.get(i).getHandleComments());
			form.setWldspsj(list.get(i).getHandleCommentsTime());
			form.setWldspxm(list.get(i).getAssigneeName());
			break;
			}
		}
		form.setWldsp(wldspYj.toString());
	}
	
    /**
     * 查看正式企业信息前检查数据
     * @return
     * @throws Exception
     */
    public String checkViewData() throws Exception{
        String qyid=getRequest().getParameter("qyid");
        YwComFinalQyxx finalQyxx=ywRqQyjyxkService.getYwComFinalQyxx(Long.valueOf(qyid));
        if(finalQyxx==null){
           getResponse().getWriter().print("dataNotExist");
        }
        
        return null;
    }
    
	//打印 呈批表经办人意见
		private void cpbJbrspUtil(){
			String names = "'jbrsl' , 'jbrsj'";
			List<Jbpm4HistTask> list = wfServiceEX.getHandleCommentsByTaskInstDbidAndActivityNames(getTaskInstDbid(),names);
			StringBuffer jbrspYj = new StringBuffer();
			for(int i=list.size()-1;i>=0;i--){//只取一条记录
				if(StringUtils.isNotBlank(list.get(i).getHandleComments())){
				jbrspYj.append(list.get(i).getHandleComments()).append("\n")
				.append("    ").append(list.get(i).getAssigneeName()).append("\n")
				.append(simpleDateFormat.format(list.get(i).getHandleCommentsTime())).append("\n");
				 break;
				}
			}
			form.setCpbJbryj(jbrspYj.toString());
		}
		//打印  呈批表 处领导意见
		private void cpbCldspUtil(){
			String names = "'cfgldsh' , 'czgldsh'";
			List<Jbpm4HistTask> list = wfServiceEX.getHandleCommentsByTaskInstDbidAndActivityNames(getTaskInstDbid(),names);
			StringBuffer cldspYj = new StringBuffer();
			for(int i=list.size()-1;i>=0;i--){//只取一条记录
				if(StringUtils.isNotBlank(list.get(i).getHandleComments())){
				cldspYj.append(list.get(i).getHandleComments()).append("\n")
				.append("    ").append(list.get(i).getAssigneeName()).append("\n")
				.append(simpleDateFormat.format(list.get(i).getHandleCommentsTime())).append("\n");
				break;
				}
			}
			form.setCpbCldyj(cldspYj.toString());
		}
		//打印  呈批表 委领导意见
		private void cpbWldspUtil(){
			String names = "'wfgldsh' , 'wzgldsp'";
			List<Jbpm4HistTask> list = wfServiceEX.getHandleCommentsByTaskInstDbidAndActivityNames(getTaskInstDbid(),names);
			StringBuffer wldspYj = new StringBuffer();
			for(int i=list.size()-1;i>=0;i--){//只取一条记录
				if(StringUtils.isNotBlank(list.get(i).getHandleComments())){
					wldspYj.append(list.get(i).getHandleComments()).append("\n")
					.append("    ").append(list.get(i).getAssigneeName()).append("\n")
					.append(simpleDateFormat.format(list.get(i).getHandleCommentsTime())).append("\n");
					break;
				}
			}
			form.setCpbWldyj(wldspYj.toString());
		}
		
		
	/**
	 * 窗口导入前检查
	 * @return
	 * @throws Exception
	 */	
	public String checkImportData() throws Exception{
        String qyid=getRequest().getParameter("qyid");
        String id=getRequest().getParameter("id");
        String templateCode=getRequest().getParameter("templateCode");
        String acceptNo=getRequest().getParameter("acceptNo");
        String contextpath=getRequest().getSession().getServletContext().getRealPath("");
        //先查询收件材料是否存在
        boolean flag=ywRqQyjyxkService.checkData(templateCode,Long.valueOf(id),Long.valueOf(qyid));
        if(flag){
        	//检查人员是否在其他企业重复
        	String result=ywRqQyjyxkService.checkPerson(contextpath,templateCode,Long.valueOf(id),Long.valueOf(qyid));
        	//renderJson("{\"error\":"+result+"}");
        	getResponse().getWriter().print(result);
            //YwComFinalQyxx finalQyxx=ywRqQyjyxkService.getYwComFinalQyxx(Long.valueOf(qyid));
//            YwComQyxx qyxx=ywRqQyjyxkService.getYwComQyxx(Long.valueOf(qyid), acceptNo);
//            if(qyxx!=null){
//                getResponse().getWriter().print("exist");
//            }
        }else{
            getResponse().getWriter().print("dataNotExist");
        }
	    
	    return null;
	}
		
    /**
     * 窗口收案环节导入数据
     */
    public String  importFinalData() throws Exception{
        Map map=getMapByRequest(getRequest());
        String contextPath=getRequest().getSession().getServletContext().getRealPath("");
        map.put("contextPath", contextPath);
        String result=ywRqQyjyxkService.importFinalData(form,map);
        getResponse().getWriter().print(result);
        return null;
    }
    
    /**
     *获取返回后导入的数据
     * @return
     * @throws IOException 
     */
    public String getResultImportData () throws IOException{
       if(form!=null && form.getId()!=null){
           JSONObject jsonObject = JSONObject.fromObject(form); 
           getResponse().getWriter().print(jsonObject.toString());
       }
        return null;
    }
    
    
   /**
    * 转为map
    * @param jsonStr
    * @param notputKey 不需要转换的key
    * @return
    * @author @zhangjun
    * @date 2011-10-17
    */
    private static Map jsonToMap(String jsonStr,String notputKey){
		Map map=new HashMap();
		JSONObject json=JSONObject.fromObject(jsonStr);
		Iterator keys=json.keys();
		while(keys.hasNext()){
			String key=(String) keys.next();
			String value=json.get(key).toString();
			if(StringUtils.isNotBlank(notputKey) &&!key.equals(notputKey)){
				if(value.startsWith("{")&&value.endsWith("}")){
					map.put(key, jsonToMap(value,notputKey));
				}else{
					map.put(key, value);
				}
		  }
		}
		return map;
	}
    
    //获取request对象中所有参数，并设置到map中
    private  Map getMapByRequest(HttpServletRequest request) {
        Map<String, String> map = new HashMap<String, String>();
        Enumeration enu = request.getParameterNames();
        while(enu.hasMoreElements()) {   
            String paraName = (String)enu.nextElement();   
            String paraValue = request.getParameter(paraName).trim(); 
            if(paraValue!=null && !"".equals(paraValue)){
                map.put(paraName, paraValue);
            }
        }  
        return map;
    }
    
    //制作补交受理通知书的时候，先检查是否填写了补交受理表的补交材料
	public void checkedBjclqd() throws Exception {
		System.out.println("form.getBjclqd() +++++++++= "+form.getBjclqd());
		if(StringUtils.isBlank(form.getBjclqd())){
			getResponse().getWriter().print("请先填写并保存补交受理材料清单！");
    	}else{
    		getResponse().getWriter().print("success");
    	}
	}
		
	public YwRqQyjyxkForm getModel() {
		return form;
	}
	
	// 属性getter和setter方法
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long[] getCheckedIds() {
		return checkedIds;
	}

	public void setCheckedIds(Long[] checkedIds) {
		this.checkedIds = checkedIds;
	}
	
	public Page<YwRqQyjyxkForm> getPage() {
		return page;
	}


	public void setPage(Page<YwRqQyjyxkForm> page) {
		this.page = page;
	}
}
